<?php session_start(); ?>
<?php include("../inc/db_config.inc"); ?>
<?php 
$g_title="添加新文章";
$g_tab="index";
$stab="post_add";
$g_header=""; 
$g_js='<script type="text/javascript" src="../editor/kindeditor.js"></script> 
<script type="text/javascript">
var a="xiaoshan"; 
KE.show({
                id : "Content",
                skinType:"default",
                allowUpload:true,
                allowFileManager:true
        });
$(document).ready(function(){
    $("#catalog_addbtn").click(function(){
        $("#catalog_add").show();
        $("#cataName").focus();
    })
    $("#cataCancel").click(function(){
        $("#catalog_add").hide();
    })
    $("#cataAddBtn").click(function(){
        var name=$("#cataName").val();
        $.ajax({
            type:"POST",
            url:"cata_add_action.php",
            "data":{title:name,format:"json"},
            success:function(json){
                var obj=eval("("+json+")");
                var status=obj.Status;
                if(obj.ID){
                    $("#cataList").append("<option value=\'"+obj.ID+"\'>"+name+"</option>");
                    $("#catalog_add").hide();
                    $("#cataList").val(obj.ID);
                }
                alert(obj.ReturnCode);
                //if(status==1){
                //    window.location.reload();
                //}
            },
            error:function(){
                alert("error");
            }
        })
    })
})
</script>';
?>
 <?php include('header.php'); ?>
			<div class="crumb"></div>
			<div class="main">
				<div class="container r">
					<div class="conbox">
						<div class="cb_hd">
							<span class="cb_tl"></span>
							<span class="cb_tr"></span>
							<h2>添加文章</h2>
						</div>
						<div class="cb_bd">
								<form class="sendbox" action="post_add_action.php" method="post">
									<p>
										<label>标题:</label><input name="title" class="txt" type="text"/>
									</p>
									<p>
										<label>分类:</label>
                                        <select name="type" id="cataList">
                                        <option value="">请选择</option>
                                        <?php
                                         $result_type=mysql_query("select * from type");
                                         while($row_type=mysql_fetch_array($result_type)){
                                         ?>
                                            <option value="<?php echo $row_type['id']; ?>"><?php echo $row_type['name']; ?></option>
                                            <?php } ?>
                                        </select>
                                        <a id="catalog_addbtn" href="javascript:void(0)">添加分类</a>
                                        <div id="catalog_add" class="dn"><input id="cataName" type="text"/><input id="cataAddBtn" type="button" class="common_btn" value="确定" /><input id="cataCancel" class="common_btn" type="button" value="取消" /></div>
									</p>
                                    <p>
										<label>是否允许评论:</label><input checked="checked" name="allowComment" value="1" type="radio"/>是 <input name="allowComment" value="0" type="radio"/>否
									</p>
                                    <p>
										<label>评论是否需要审核:</label><input checked="checked" name="commentAudit" value="1" type="radio"/>是 <input name="commentAudit" value="0" type="radio"/>否
									</p>
									<p>
										<label>内容:</label><div style="margin-left: 25px;"><textarea id="Content" name="content"></textarea></div>
									</p>
                                    
									<p>
										<input class="sub" type="submit" value="提交"/>
									</p>
								</form>
						</div>
						<div class="cb_ft"></div>
					</div>
				</div>
				<?php include('sidebar.php'); ?>
				<div class="c"></div>
			</div>
		</div>
	</div>
<?php include('footer.php'); ?>
